<?php

namespace common\models\c2\entity;

use Yii;

/**
 * This is the model class for table "{{%be_access_token}}".
 *
 * @property int $id
 * @property int $type
 * @property int $user_id
 * @property string $access_token
 * @property string $expired_at
 * @property string $equipment_id
 * @property int $status
 * @property string $created_at
 * @property string $updated_at
 */
class AccessToken extends \common\models\base\ActiveRecord
{

    const EXPIRED_TIME = 7200;
    /**
     * {@inheritdoc}
     */
    public static function tableName()
    {
        return '{{%access_token}}';
    }

    /**
     * {@inheritdoc}
     */
    public function rules()
    {
        return [
            [['type', 'user_id', 'status'], 'integer'],
            [['user_id', 'access_token'], 'required'],
            [['access_token',], 'unique'],
            [['created_at', 'updated_at', 'expired_at'], 'safe'],
            [['access_token'], 'string', 'max' => 64],
            [['equipment_id'], 'string', 'max' => 255],
        ];
    }

    /**
     * {@inheritdoc}
     */
    public function attributeLabels()
    {
        return [
            'id' => Yii::t('app.c2', 'ID'),
            'type' => Yii::t('app.c2', 'Type'),
            'user_id' => Yii::t('app.c2', 'User ID'),
            'access_token' => Yii::t('app.c2', 'Access Token'),
            'expired_at' => Yii::t('app.c2', 'Expired At'),
            'equipment_id' => Yii::t('app.c2', 'Equipment ID'),
            'status' => Yii::t('app.c2', 'Status'),
            'created_at' => Yii::t('app.c2', 'Created At'),
            'updated_at' => Yii::t('app.c2', 'Updated At'),
        ];
    }

}
